package com.example.api.service;

import com.example.api.config.FeignRequestConfig;
import com.example.api.module.user.vo.UserVO;
import com.example.api.service.impl.UserFailBack;
import com.example.common.api.ResultUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

@Component
@FeignClient(value = "demo-user", fallback = UserFailBack.class, configuration = FeignRequestConfig.class, dismiss404 = true)  //value中是调用服务的名称，这个要对应服务名称
public interface IUserFeignService {

    @PostMapping(value = "/login", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    ResultUtil login(@RequestParam String mobile, @RequestParam String password);

    @PostMapping(value = "/create_user", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    ResultUtil createUser(@RequestBody UserVO userVO);

    @GetMapping(value = "/api/user/get_user", produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    ResultUtil getUser(@RequestParam("mobile") String mobile,
                       @RequestParam("password") String password);
}
